package com.conversationboard.view;

import java.sql.SQLException;
import java.util.List;

import com.conversationboard.config.Configuration;
import com.conversationboard.model.SiteInfo;

public class SiteInfoDisplay {

    public static String display() throws SQLException {

        List<String> recentlyRegisteredUsers = SiteInfo.getRecentlyRegisteredUsers();
        int totalUsers = SiteInfo.getNumberOfRegisteredUsers();
        StringBuilder buffer = new StringBuilder();

        buffer.append("<p>Users Registered in the Last Week:<p>");

        buffer.append("<table class='table'>");

        buffer.append("<tr class='header'><td class='cell'>User</td></tr>");
        
        for (String user : recentlyRegisteredUsers) {
            buffer.append("<tr><td class='cell'><a href='" + Configuration.getInstance().getRoot() + "/Admin/AdminUserInfoControllerServlet?userid=" + user + "'>" + user + "</a></td></tr>");
        }

        buffer.append("</table>");

        buffer.append("<p>Total Number of Registered Users: " + totalUsers + "</p>");
        
        return buffer.toString();

    }
}
